const config = require('../../../config/config.local');
const amazonMws = require('amazon-mws')(config.AWSAccessKeyId, config.AWSSecretKey);
const isProduction = process.env.NODE_ENV === 'production';

const requestReport = {};

requestReport.generateOption = function(seller_id, mws_auth_token, reportType){
  let baseOption = {
    'Version': '2009-01-01',
    'Action': 'RequestReport',
    'SellerId': seller_id,
    'MWSAuthToken': mws_auth_token,
    'ReportType': reportType,
  };

  return baseOption;
};

requestReport._ = function(options) {
  if (!isProduction) {
    return amazonMws.reports.submit(options);
  } else {
    console.error("bot not implemented!")
  }
};

requestReport.requestReport = function(seller_id, mws_auth_token, reportType) {
  return this._(this.generateOption(seller_id, mws_auth_token, reportType));
};

module.exports = requestReport;